﻿using System;
using System.Collections.Generic;

namespace NMA.Infrastructure.NHibernate.DomainObject
{
    using NMA.Domain.Shared;
    using NMA.Infrastructure.DBC;    
    using NMA.Domain.Model;

    public class Category : BaseEntity<ICategory>, INameEntity<ICategory>, ICategory
    {
        public virtual string Name { get; set; }

        public virtual string CreatedUser { get; set; }

        public virtual string UpdatedUser { get; set; }

        public virtual IList<INews> News { get; set; }

        public Category()
        {            
            InitNews();
        }

        public virtual void InitNews()
        {
            News = new List<INews>();
        }

        public virtual void AddNews(INews news)
        {
            news.Category = this;
            News.Add(news);
        }

        public override bool SameIdentityAs(ICategory other)
        {
            Check.Assert(other == null, "Category is null");

            return this.Id == other.Id;
        }
    }
}
